#include <stdio.h>

int main(int argc, char *argv[])
{

    int y, m, d, allday = 0;

    int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    while (scanf("%d/%d/%d", &y, &m, &d) != EOF)
    {
        if ((y % 4 == 4 && y % 100 != 0) || y % 400 == 0)
            days[1] = 29;

        if (m == 1)
            printf("%d\n", d);
        else
        {
            for (size_t i = 0; i < m - 1; i++)
                allday += days[i];

            allday += d;
            printf("%d\n", allday);
        }
    }

    return 0;
}